#!/bin/bash
set -e

# Official docker instructions from https://docs.docker.com/engine/install/debian/#install-using-the-repository
apt-get update
apt-get install -qy \
  ca-certificates \
  curl \
  gnupg \
  lsb-release
mkdir -p /etc/apt/keyrings
if [ ! -f /etc/apt/keyrings/docker.gpg ]; then
  curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
fi
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install -qy docker-ce docker-ce-cli containerd.io docker-compose-plugin

# iproute2 is needed for docker-in-docker script (ip command)
apt install -qy iproute2
